#define _CRT_SECURE_NO_WARNINGS 1
//密码检查
#include <stdio.h>
#include <string.h>

void Judge_PIN(char arr[101],  int len)
{
	//密码至少为8位
	if (len < 8)
	{
		printf("NO");
		return;
	}
	//密码不能以数字开头
	if (arr[0] >= '0' && arr[0] <= '9')
	{
		printf("NO");
		return;
	}
	int i = 0;
	int big = 0;
	int small = 0;
	int num = 0;
	int other = 0;
	for (i = 0; i < len; i++)
	{
		if (arr[i] >= 'A' && arr[i] <= 'Z')
		{
			big++;
		}
		else if (arr[i] >= 'a' && arr[i] <= 'z')
		{
			small++;
		}
		else if (arr[i] >= '0' && arr[i] <= '9')
		{
			num++;
		}
		else
		{
			other++;
		}
	}
	//密码只能由大写字母，小写字母，数字构成
	if (other != 0)
	{
		printf("NO");
		return;
	}
	//密码中至少出现大写字母，小写字母和数字这三种字符类型中的两种
	if ((big > 0) + (small > 0) + (num > 0) < 2)
	{
		printf("NO");
		return;
	}
	else
	{
		printf("YES");
		return;
	}
}

int main()
{
	int n = 0;
	scanf("%d", &n);
	int i = 0;
	char arr[101] = { 0 };
	for (i = 1; i < n; i++)
	{
		scanf("%d",arr);
		int len = strlen(arr);
		Judge_PIN(arr, len);
	}
	return 0;
}